/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.nxlv2.nomad.accessdb.services;

import com.nxlv2.nomad.accessdb.dao.IArticleDao;
import com.nxlv2.nomad.accessdb.dao.IPrixDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcArticleDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcPrixDao;
import com.nxlv2.nomad.businessobjects.Article;
import com.nxlv2.nomad.businessobjects.Prix;
import com.nxlv2.nomad.businessobjects.Tva;

/**
 *
 * @author Administrateur
 */
public class PrixServices {
    private static final  IPrixDao dao = new JdbcPrixDao();
    private static final IArticleDao daoA = new JdbcArticleDao();
    
    /**
     * 
     * @param prix
     * @param article
     * @throws ServiceException 
     */
    public void create (Prix prix, Article article) throws ServiceException {
        dao.savePrix(prix);
        daoA.lierPrixAArticle(prix, article);
    }
    
    /**
     * 
     * @param prix
     * @throws ServiceException 
     */
    public void update (Prix prix) throws ServiceException {      
        dao.updatePrix(prix);
    }
    
    /**
     * 
     * @param prix
     * @throws ServiceException 
     */
    public void delete (Prix prix) throws ServiceException {
        dao.deletePrix(prix.getIdAppli());
    }
    
    /**
     * 
     * @param id
     * @return
     * @throws ServiceException 
     */
    public Prix get (int id) throws ServiceException {
        return dao.findPrixById(id);
    }
    
    /**
     * 
     * @param prix
     * @return Tva
     * @throws ServiceException 
     */
    public Tva getTva(Prix prix) throws ServiceException {
        return dao.getTva(prix); 
    }
    
    /**
     * 
     * @param tva
     * @param prix
     * @throws ServiceException 
     */
    public void linkTva(Tva tva, Prix prix) throws ServiceException {
        dao.lierTvaAPrix(tva, prix);
    }
    
}
